// 发送ajax请求
import config from './config';

export default (url, data = {}, method = 'GET',header = {}) => {
    return new Promise((resolve,reject) => {
        wx.request({
            url: config.host + url,
            data,
            method,
            header,
            success: (res) => {
                resolve(res.data);  //修改promise的状态为成功状态resolved
            },
            fail: (err) => {
                reject(err);        //修改promise的状态为失败状态rejected
            }
        })
    })
}
